package com.deyuanyun.pic.pbf.controller.dto.defect.measure;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pbf.controller.dto.defect.ImgDto;
import com.deyuanyun.pic.pbf.domain.DefectInfo;
import com.deyuanyun.pic.pbf.domain.DefectMeasure;
import com.deyuanyun.pic.pbf.enumeration.ImgCustomType;
import com.deyuanyun.pic.settings.domain.base.Attachment;
import com.deyuanyun.pic.settings.support.biz.AttachmentUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 3，“焊缝”缺陷测量记录
 *
 * @author hlw
 * @date 2016-6-28
 *
 * History: [修改人][时间][修改描述]
 */
public class WeldMeasureDto extends MeasureDto<DefectMeasure> {

    /**
     * 绝对距离
     */
    private String mileage;

    /**
     * 长（mm）
     */
    private String length;

    /**
     * 宽（mm）
     */
    private String width;

    /**
     * 时钟位置
     */
    private String clock;

    /**
     * 实测：长（mm）
     */
    private String actualLength;

    /**
     * 实测：宽（mm）
     */
    private String actualWidth;

    /**
     * 实测：时钟位置
     */
    private String actualClock;

    /**
     * 无损检测报告编号
     */
    private String ndtReportNumber;

    /**
     * 缺陷描述
     */
    private String defectDescription;

    /**
     * 是否完成该节点任务：0，没有完成；1，已经完成
     */
    private Short isCompletion;

    public WeldMeasureDto(Short isCompletion) {
        this.isCompletion = isCompletion;
    }

    public Short getIsCompletion() {
        return isCompletion;
    }

    public void setIsCompletion(Short isCompletion) {
        this.isCompletion = isCompletion;
    }


    public WeldMeasureDto(DefectInfo defectInfo, Short isCompletion) {
        super(defectInfo);
        this.isCompletion = isCompletion;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    public String getWidth() {
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public String getClock() {
        return clock;
    }

    public void setClock(String clock) {
        this.clock = clock;
    }

    public String getActualLength() {
        return actualLength;
    }

    public void setActualLength(String actualLength) {
        this.actualLength = actualLength;
    }

    public String getActualWidth() {
        return actualWidth;
    }

    public void setActualWidth(String actualWidth) {
        this.actualWidth = actualWidth;
    }

    public String getActualClock() {
        return actualClock;
    }

    public void setActualClock(String actualClock) {
        this.actualClock = actualClock;
    }

    public String getNdtReportNumber() {
        return ndtReportNumber;
    }

    public void setNdtReportNumber(String ndtReportNumber) {
        this.ndtReportNumber = ndtReportNumber;
    }

    public String getDefectDescription() {
        return defectDescription;
    }

    public void setDefectDescription(String defectDescription) {
        this.defectDescription = defectDescription;
    }

    public void fromDomain(DefectMeasure domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 赋值
        super.fromDomain(domain);

        // 绝对距离
        this.mileage = NumberFormat.format(defectInfo.getMileage());
        // 长（mm）
        this.length = NumberFormat.format(defectInfo.getLength());
        // 宽（mm）
        this.width = NumberFormat.format(defectInfo.getWidth());
        // 时钟位置
        this.clock = defectInfo.getClock();
        // 实测：长（mm）
        this.actualLength = NumberFormat.format(domain.getActualLength());
        // 实测：宽（mm）
        this.actualWidth = NumberFormat.format(domain.getActualWidth());
        // 实测：时钟位置
        this.actualClock = domain.getActualClock();
        // 无损检测报告编号
        this.ndtReportNumber = domain.getNdtReportNumber();
        // 缺陷描述
        this.defectDescription = domain.getDefectDescription();

        // 图片:类型
        this.setImgList(ImgDto.queryClassifyImgDto(domain.getId(), new ImgCustomType[]{ImgCustomType.ALL, ImgCustomType.NDTTYPE}));
    }
}